<template>
  <div>
    <el-row :gutter="15">

      <el-tabs v-model="activexdivdv" tab-position="top" class="mb-20">
        <el-tab-pane label="原数据">

          <el-form ref="elForm"   :disabled="true"  :model="dataForm.oldData" size="small" label-width="100px"
                   label-position="right"
          >
            <template>
              <!--          v-if="!loading && formOperates"-->
              <el-card class="mb-20" shadow="always" header="商务条款">

                  <el-col :span="8" v-if="judgeShow('htType')"
                  >
                    <el-form-item label="合同类型"
                                  prop="htType"
                    >
                      <el-select v-model="dataForm.oldData.htType"
                                 placeholder="请选择" :disabled="judgeWrite('htType')" clearable
                                 :style='{"width":"100%"}'
                      >
                        <el-option v-for="(item, index) in htTypeOptions" :key="index" :label="item.fullName"
                                   :value="item.fullName" :disabled="item.disabled"
                        ></el-option>

                      </el-select>
                    </el-form-item>
                  </el-col>

                  <el-col :span="8" v-if="judgeShow('startTime')"
                  >
                    <el-form-item label="合同起始日期"
                                  prop="startTime"
                    >
                      <el-date-picker v-model="dataForm.oldData.startTime"
                                      @change="check(dataForm.oldData)"
                                      placeholder="请选择" :disabled="judgeWrite('startTime')" clearable
                                      :style='{"width":"100%"}' type="date" format="yyyy-MM-dd" value-format="timestamp"
                      >

                      </el-date-picker>
                    </el-form-item>
                  </el-col>

                  <el-col :span="8" v-if="judgeShow('endTime')"
                  >
                    <el-form-item label="合同结束日期"
                                  prop="endTime"
                    >
                      <el-date-picker v-model="dataForm.oldData.endTime"
                                      @change="check(dataForm.oldData)"
                                      placeholder="请选择" :disabled="judgeWrite('endTime')" clearable
                                      :style='{"width":"100%"}' type="date" format="yyyy-MM-dd" value-format="timestamp"
                      >

                      </el-date-picker>
                    </el-form-item>
                  </el-col>

                  <el-col :span="8" v-if="judgeShow('contractPeriod')"
                  >
                    <el-form-item label="合同期限"
                                  prop="contractPeriod"
                    >
                      <el-input v-model="dataForm.oldData.contractPeriod"
                                placeholder="请输入" :disabled="judgeWrite('contractPeriod')" clearable
                                :style='{"width":"100%"}'
                      >

                      </el-input>
                    </el-form-item>
                  </el-col>

                  <el-col :span="8" v-if="judgeShow('advancePaymentDays')">
                    <el-form-item label="提前缴费天数" prop="advancePaymentDays">
                      <el-input-number
                        v-model="dataForm.oldData.advancePaymentDays"
                        placeholder="请输入"
                        :disabled="judgeWrite('advancePaymentDays')"
                        :style='{"width":"100%"}'
                        clearable
                        :min="0"
                        :max="10000"
                      />
                    </el-form-item>
                  </el-col>

                  <el-col :span="24">
                    <el-card class="mb-20" shadow="always" header="租赁资产">
                      <el-col :span="24" v-if="judgeShow('zcglhtglpabspaceList') && formOperates">
                        <el-form-item label-width="0">
                          <div class="JNPF-common-title">
                            <h2></h2>
                          </div>
                          <el-table :data="dataForm.oldData.zcgl_htgl_pab_space1" size="mini">
                            <el-table-column type="index" width="70" label="序号" align="center"/>
                            <el-table-column prop="zcname" label="资产名称"
                                             v-if="judgeShow('zcglhtglpabspaceList-spaceName')"
                            >
                              <template slot="header" v-if="judgeRequired('zcglhtglpabspaceList-spaceName')">
                                <span class="required-sign">*</span>资产名称
                              </template>
                              <template slot-scope="scope">
                                <el-input v-model="scope.row.zcname"
                                          placeholder="请输入"
                                          :disabled="judgeWrite('zcglhtglpabspaceList') || judgeWrite('zcglhtglpabspaceList-spaceName')"
                                          clearable :style='{"width":"100%"}'
                                >
                                </el-input>
                              </template>
                            </el-table-column>
                            <!--                        <el-table-column prop="zcnumber" label="经营面积"-->
                            <!--                                         v-if="judgeShow('zcglhtglpabspaceList-operatingArea')"-->
                            <!--                        >-->
                            <!--                          <template slot="header" v-if="judgeRequired('zcglhtglpabspaceList-operatingArea')">-->
                            <!--                            <span class="required-sign">*</span>资产编码-->
                            <!--                          </template>-->
                            <!--                          <template slot-scope="scope">-->
                            <!--                            <el-input v-model="scope.row.zcnumber"-->
                            <!--                                      placeholder="请输入"-->
                            <!--                                      :disabled="judgeWrite('zcglhtglpabspaceList') || judgeWrite('zcglhtglpabspaceList-operatingArea')"-->
                            <!--                                      clearable :style='{"width":"100%"}'-->
                            <!--                            >-->
                            <!--                            </el-input>-->
                            <!--                          </template>-->
                            <!--                        </el-table-column>-->
                            <el-table-column prop="address" label="资产地址"
                                             v-if="judgeShow('zcglhtglpabspaceList-spaceType')"
                            >
                              <template slot="header" v-if="judgeRequired('zcglhtglpabspaceList-spaceType')">
                                <span class="required-sign">*</span>资产地址
                              </template>
                              <template slot-scope="scope">
                                <el-input v-model="scope.row.address"
                                          placeholder="请输入"
                                          :disabled="judgeWrite('zcglhtglpabspaceList') || judgeWrite('zcglhtglpabspaceList-spaceType')"
                                          clearable :style='{"width":"100%"}'
                                >
                                </el-input>
                              </template>
                            </el-table-column>

                            <el-table-column prop="buildingmeasurementarea" label="建筑测量面积"
                                             v-if="judgeShow('zcglhtglpabspaceList-buildingmeasurementarea')"
                            >
                              <template slot="header" v-if="judgeRequired('zcglhtglpabspaceList-buildingmeasurementarea')">
                                <span class="required-sign">*</span>建筑测量面积
                              </template>
                              <template slot-scope="scope">
                                <el-input v-model="scope.row.zcgl_zcdj_area.buildingmeasurementarea"
                                          placeholder="请输入"
                                          :disabled="judgeWrite('zcglhtglpabspaceList') || judgeWrite('zcglhtglpabspaceList-buildingmeasurementarea')"
                                          clearable :style='{"width":"100%"}'
                                >
                                </el-input>
                              </template>
                            </el-table-column>

                            <el-table-column label="操作" width="50"
                                             v-if="!setting.readonly && !judgeWrite('zcglhtglpabspaceList')"
                            >
                              <template slot-scope="scope">
                                <el-button size="mini" type="text" class="JNPF-table-delBtn"
                                           @click="delzcglhtglpabspaceList(scope.$index)"
                                >删除
                                </el-button>
                              </template>
                            </el-table-column>
                          </el-table>
                          <div class="table-actions" @click="addzcglhtglpabspaceList()">
                            <!--                          <el-button type="text" icon="el-icon-plus">添加</el-button>-->
                            <Popup v-model="dataForm.oldData.lastmodifytime"
                                   @addList="handleAddList"
                                   placeholder="请选择" clearable field="assetName" interfaceId="612769091110831365"
                                   :columnOptions="lastmodifytimecolumnOptions" propsValue="id" relationField="zcname"
                                   popupType="dialog"
                                   popupTitle="选择资产" popupWidth="800px"
                                   hasPage :pageSize="20"
                            >
                            </Popup>
                          </div>
                        </el-form-item>
                      </el-col>
                    </el-card>
                  </el-col>

                  <el-col :span="24">
                    <el-card class="mb-20" shadow="always" header="租金费用条款">

                      <el-row v-for="(item, index) in dataForm.oldData.zcgl_htgl_pab_fytk" :key="index">
                        <el-row>

                          <el-col :span="6" v-if="judgeShow('jnpf_zcgl_htgl_pab_fytk_jnpf_startTime')"
                          >
                            <el-form-item label="关联资产"
                                          :prop="getItemProp_zcgl_htgl_pab_fytk(index, 'relatedSpace')"
                            >
                              <!--                            :disabled="judgeWrite('relatedSpace')"-->
                              <el-select multiple v-model="item.relatedSpace"
                                         clearable
                                         :style='{"width":"100%"}'
                                         @change="toGetArea(item)"
                              >
                                <el-option v-for="(item, index) in dataForm.oldData.zcgl_htgl_pab_space1" :key="index"
                                           :label="item.zcname"
                                           :value="item.id" :disabled="item.disabled"
                                ></el-option>
                                <!--                        <el-form-item label="关联资产"-->
                                <!--                                      :prop="getItemProp_zcgl_htgl_pab_fytk(index, 'relatedSpace')"-->
                                <!--                        >-->
                                <!--                          &lt;!&ndash;                            :disabled="judgeWrite('relatedSpace')"&ndash;&gt;-->
                                <!--                          <el-select multiple v-model="item.relatedSpace"-->
                                <!--                                     clearable-->
                                <!--                                     :style='{"width":"100%"}'-->
                                <!--                                     @change="toGetArea(item)"-->
                                <!--                          >-->
                                <!--                            <el-option v-for="(item, index) in dataForm.zcgl_htgl_pab_space1" :key="index"-->
                                <!--                                       :label="item.zcname"-->
                                <!--                                       :value="item.id" :disabled="item.disabled"-->
                                <!--                            ></el-option>-->

                              </el-select>
                            </el-form-item>
                            <!--                          </el-select>-->
                            <!--                        </el-form-item>-->
                          </el-col>

                          <el-col :span="6" v-if="judgeShow('rentalArea')"
                          >
                            <el-form-item label="租赁面积㎡"
                                          prop="rentalArea"
                            >
                              <el-input v-model="dataForm.oldData.rentalArea"
                                        placeholder="请输入" :disabled="judgeWrite('rentalArea')"
                                        clearable :style='{"width":"100%"}'
                              >
                              </el-input>
                            </el-form-item>
                          </el-col>

                          <el-col :span="6" v-if="judgeShow('jnpf_zcgl_htgl_pab_fytk_jnpf_startTime')"
                          >
                            <el-form-item
                              :prop="getItemProp_zcgl_htgl_pab_fytk(index, 'rentMethod')"
                              label="计租方式"
                            >
                              <!--                            :disabled="judgeWrite('relatedSpace')"-->
                              <el-select
                                v-model="item.rentMethod"
                                clearable
                                :style="{ width: '100%' }"
                              >
                                <el-option
                                  label="固定租金"
                                  value="固定租金"
                                ></el-option>
                              </el-select>
                            </el-form-item>
                          </el-col>

                          <el-col :span="6" v-if="judgeShow('jnpf_zcgl_htgl_pab_fytk_jnpf_startTime')"
                          >
                            <el-form-item label="费用项"
                                          :prop="getItemProp_zcgl_htgl_pab_fytk(index, 'expenseType')"
                            >
                              <!--                            :disabled="judgeWrite('relatedSpace')"-->
                              <el-select

                                v-model="item.expenseType"
                                clearable
                                :style="{ width: '100%' }"
                              >
                                <el-option
                                  label="房屋租金"
                                  value="1"
                                ></el-option>
                                <el-option
                                  label="物业"
                                  value="2"
                                ></el-option>
                              </el-select>
                            </el-form-item>
                          </el-col>
                        </el-row>

                        <el-row>

                          <el-col :span="6" v-if="judgeShow('jnpf_zcgl_htgl_pab_fytk_jnpf_taxRate')">
                            <el-form-item label="税率(%)" prop="jnpf_zcgl_htgl_pab_fytk_jnpf_taxRate">
                              <el-input-number
                                v-model="item.taxRate"
                                placeholder="数字文本"
                                :disabled="judgeWrite('jnpf_zcgl_htgl_pab_fytk_jnpf_taxRate')"
                                :step="0.01"
                                :precision="2"
                              />
                            </el-form-item>
                          </el-col>

                          <el-col :span="6" v-if="judgeShow('jnpf_zcgl_htgl_pab_fytk_jnpf_hsUnit')"
                          >
                            <el-form-item label="含税租金单价(元)"
                                          prop="hsUnitPrice"
                            >
                              <el-input-number v-model="item.hsUnitPrice"
                                               placeholder="数字文本"
                                               :disabled="judgeWrite('jnpf_zcgl_htgl_pab_fytk_jnpf_hsUnit')"
                                               :step="0.01"
                                               :precision="2"
                              >
                              </el-input-number>
                            </el-form-item>
                          </el-col>

                          <el-col :span="6" v-if="judgeShow('jnpf_zcgl_htgl_pab_fytk_jnpf_bhsUnit')"
                          >
                            <el-form-item label="不含税租金单价(元)"
                                          prop="bhsUnitPrice"
                            >
                              <el-input-number v-model="item.bhsUnitPrice"
                                               placeholder="数字文本"
                                               :disabled="judgeWrite('jnpf_zcgl_htgl_pab_fytk_jnpf_bhsUnit')"
                                               :step="0.01"
                                               :precision="2"
                              >
                              </el-input-number>
                            </el-form-item>
                          </el-col>

                          <el-col :span="6"
                          >
                            <el-form-item label="月租金(元)"
                                          :prop="getItemProp_zcgl_htgl_pab_fytk(index, 'monthlyRent')"
                            >
                              <el-input-number v-model="item.monthlyRent"
                                               placeholder="数字文本"
                                               :disabled="judgeWrite('jnpf_zcgl_htgl_pab_fytk_jnpf_bhsUnit')"
                                               :step="0.01"
                                               :precision="2"
                              >
                              </el-input-number>
                            </el-form-item>
                          </el-col>

                        </el-row>

                        <el-row>
                          <el-col :span="6"
                          >
                            <el-form-item label="保证金(元)"
                                          :prop="getItemProp_zcgl_htgl_pab_fytk(index, 'jnpf_zcgl_htgl_pab_fytk_jnpf_bhsUnit')"
                            >
                              <el-input-number v-model="item.earnestMoney"
                                               placeholder="数字文本"
                                               :disabled="judgeWrite('jnpf_zcgl_htgl_pab_fytk_jnpf_bhsUnit')"
                                               :step="0.01"
                                               :precision="2"
                              >
                              </el-input-number>
                            </el-form-item>
                          </el-col>

                          <el-col :span="6"
                          >
                            <el-form-item label="违约金(元)"
                                          :prop="getItemProp_zcgl_htgl_pab_fytk(index, 'jnpf_zcgl_htgl_pab_fytk_jnpf_bhsUnit')"
                            >
                              <el-input-number v-model="item.defaultMoney"
                                               placeholder="数字文本"
                                               :disabled="judgeWrite('jnpf_zcgl_htgl_pab_fytk_jnpf_bhsUnit')"
                                               :step="0.01"
                                               :precision="2"
                              >
                              </el-input-number>
                            </el-form-item>
                          </el-col>

                          <el-col style="display: flex" :span="6"
                                  v-if="judgeShow('jnpf_zcgl_htgl_pab_fytk_jnpf_bhsUnit')"
                          >
                            <el-form-item label="付款周期(月)"
                                          placeholder="数字文本"
                                          :prop="getItemProp_zcgl_htgl_pab_fytk(index, 'paymentCycle')"

                            >
                              <el-input-number v-model="item.paymentCycle"
                                               :disabled="judgeWrite('jnpf_zcgl_htgl_pab_fytk_jnpf_bhsUnit')"
                                               :step="1"
                              >
                              </el-input-number>
                            </el-form-item>
                          </el-col>

                        </el-row>
                        <el-row>
                          <el-col :span="6">

                            <el-form-item label="是否递增"
                                          prop="ihis"
                            >
                              <el-switch v-model="item.isIncreasing"
                                         :disabled="judgeWrite('jnpf_zcgl_htgl_pab_fytk_jnpf_bhsUnit')" :active-value="1"
                                         :inactive-value="0"
                              >

                              </el-switch>
                            </el-form-item>
                          </el-col>


                          <el-col :span="16">
                            <el-form-item>

                              <el-button type="danger" @click.prevent="removeFytk(index)">删除</el-button>
                            </el-form-item>
                          </el-col>
                        </el-row>

                        <!--递增条款-->
                        <el-row>
                          <el-table
                            v-if="item.isIncreasing==1"
                            :data="item.listDz"
                            style="width: 100%"
                            border
                          >
                            <el-table-column
                              prop="start"
                              label="开始日期"
                              width="250"
                            />
                            <el-table-column
                              prop="end"
                              label="结束日期"
                              width="250"
                            />
                            <el-table-column
                              prop="rent"
                              label="租金单价"
                              width="250"
                            />
                            <el-table-column
                              prop="paymentDate"
                              label="付款日期"
                              width="250"
                            />
                            <el-table-column
                              prop="rent"
                              label="日期"
                              width="280"
                            />
                            <el-table-column
                              prop="increasePercent"
                              label="递增"
                              width="280"
                            />
                          </el-table>
                          <div v-if="item.isIncreasing==1" class="table-actions" @click="addzcglhtglpabspaceList()">
                            <el-button type="text" icon="el-icon-plus" @click="addDz(item)">批量新增递增条款</el-button>
                          </div>
                        </el-row>


                        <el-divider v-if="index < dataForm.oldData.zcgl_htgl_pab_fytk.length - 1"></el-divider>

                      </el-row>
                      <el-row>

                        <div class="table-actions" @click="addzcglhtglpabspaceList()">
                          <!--                          <el-button type="text" icon="el-icon-plus">添加</el-button>-->
                          <el-button type="text" icon="el-icon-plus" @click="addFytk">添加费用</el-button>
                        </div>

                      </el-row>
                    </el-card>
                  </el-col>
              </el-card>
            </template>
          </el-form>
        </el-tab-pane>

        <el-tab-pane label="变更数据">

          <el-form ref="elForm" :model="dataForm.newData" :rules="dataRule" size="small" label-width="100px"
                   label-position="right" :disabled="setting.readonly"
          >
            <template>
              <!--          v-if="!loading && formOperates"-->
              <el-card class="mb-20" shadow="always" header="商务条款">

                <el-col :span="8" v-if="judgeShow('htType')"
                >
                  <el-form-item label="合同类型"
                                prop="htType"
                  >
                    <el-select v-model="dataForm.newData.htType"
                               placeholder="请选择" :disabled="judgeWrite('htType')" clearable
                               :style='{"width":"100%"}'
                    >
                      <el-option v-for="(item, index) in htTypeOptions" :key="index" :label="item.fullName"
                                 :value="item.fullName" :disabled="item.disabled"
                      ></el-option>

                    </el-select>
                  </el-form-item>
                </el-col>

                <el-col :span="8" v-if="judgeShow('startTime')"
                >
                  <el-form-item label="合同起始日期"
                                prop="startTime"
                  >
                    <el-date-picker v-model="dataForm.newData.startTime"
                                    @change="check(dataForm.newData)"
                                    placeholder="请选择" :disabled="judgeWrite('startTime')" clearable
                                    :style='{"width":"100%"}' type="date" format="yyyy-MM-dd" value-format="timestamp"
                    >

                    </el-date-picker>
                  </el-form-item>
                </el-col>

                <el-col :span="8" v-if="judgeShow('endTime')"
                >
                  <el-form-item label="合同结束日期"
                                prop="endTime"
                  >
                    <el-date-picker v-model="dataForm.newData.endTime"
                                    @change="check(dataForm.newData)"
                                    placeholder="请选择" :disabled="judgeWrite('endTime')" clearable
                                    :style='{"width":"100%"}' type="date" format="yyyy-MM-dd" value-format="timestamp"
                    >

                    </el-date-picker>
                  </el-form-item>
                </el-col>

                <el-col :span="8" v-if="judgeShow('contractPeriod')"
                >
                  <el-form-item label="合同期限"
                                prop="contractPeriod"
                  >
                    <el-input v-model="dataForm.newData.contractPeriod"
                              placeholder="请输入" :disabled="judgeWrite('contractPeriod')" clearable
                              :style='{"width":"100%"}'
                    >

                    </el-input>
                  </el-form-item>
                </el-col>

                <el-col :span="8" v-if="judgeShow('advancePaymentDays')">
                  <el-form-item label="提前缴费天数" prop="advancePaymentDays">
                    <el-input-number
                      v-model="dataForm.newData.advancePaymentDays"
                      placeholder="请输入"
                      :disabled="judgeWrite('advancePaymentDays')"
                      :style='{"width":"100%"}'
                      clearable
                      :min="0"
                      :max="10000"
                    />
                  </el-form-item>
                </el-col>

                <el-col :span="24">
                  <el-card class="mb-20" shadow="always" header="租赁资产">
                    <el-col :span="24" v-if="judgeShow('zcglhtglpabspaceList') && formOperates">
                      <el-form-item label-width="0">
                        <div class="JNPF-common-title">
                          <h2></h2>
                        </div>
                        <el-table :data="dataForm.newData.zcgl_htgl_pab_space1" size="mini">
                          <el-table-column type="index" width="70" label="序号" align="center"/>
                          <el-table-column prop="zcname" label="资产名称"
                                           v-if="judgeShow('zcglhtglpabspaceList-spaceName')"
                          >
                            <template slot="header" v-if="judgeRequired('zcglhtglpabspaceList-spaceName')">
                              <span class="required-sign">*</span>资产名称
                            </template>
                            <template slot-scope="scope">
                              <el-input v-model="scope.row.zcname"
                                        placeholder="请输入"
                                        :disabled="judgeWrite('zcglhtglpabspaceList') || judgeWrite('zcglhtglpabspaceList-spaceName')"
                                        clearable :style='{"width":"100%"}'
                              >
                              </el-input>
                            </template>
                          </el-table-column>
                          <!--                        <el-table-column prop="zcnumber" label="经营面积"-->
                          <!--                                         v-if="judgeShow('zcglhtglpabspaceList-operatingArea')"-->
                          <!--                        >-->
                          <!--                          <template slot="header" v-if="judgeRequired('zcglhtglpabspaceList-operatingArea')">-->
                          <!--                            <span class="required-sign">*</span>资产编码-->
                          <!--                          </template>-->
                          <!--                          <template slot-scope="scope">-->
                          <!--                            <el-input v-model="scope.row.zcnumber"-->
                          <!--                                      placeholder="请输入"-->
                          <!--                                      :disabled="judgeWrite('zcglhtglpabspaceList') || judgeWrite('zcglhtglpabspaceList-operatingArea')"-->
                          <!--                                      clearable :style='{"width":"100%"}'-->
                          <!--                            >-->
                          <!--                            </el-input>-->
                          <!--                          </template>-->
                          <!--                        </el-table-column>-->
                          <el-table-column prop="address" label="资产地址"
                                           v-if="judgeShow('zcglhtglpabspaceList-spaceType')"
                          >
                            <template slot="header" v-if="judgeRequired('zcglhtglpabspaceList-spaceType')">
                              <span class="required-sign">*</span>资产地址
                            </template>
                            <template slot-scope="scope">
                              <el-input v-model="scope.row.address"
                                        placeholder="请输入"
                                        :disabled="judgeWrite('zcglhtglpabspaceList') || judgeWrite('zcglhtglpabspaceList-spaceType')"
                                        clearable :style='{"width":"100%"}'
                              >
                              </el-input>
                            </template>
                          </el-table-column>

                          <el-table-column prop="buildingmeasurementarea" label="建筑测量面积"
                                           v-if="judgeShow('zcglhtglpabspaceList-buildingmeasurementarea')"
                          >
                            <template slot="header" v-if="judgeRequired('zcglhtglpabspaceList-buildingmeasurementarea')">
                              <span class="required-sign">*</span>建筑测量面积
                            </template>
                            <template slot-scope="scope">
                              <el-input v-model="scope.row.zcgl_zcdj_area.buildingmeasurementarea"
                                        placeholder="请输入"
                                        :disabled="judgeWrite('zcglhtglpabspaceList') || judgeWrite('zcglhtglpabspaceList-buildingmeasurementarea')"
                                        clearable :style='{"width":"100%"}'
                              >
                              </el-input>
                            </template>
                          </el-table-column>

                          <el-table-column label="操作" width="50"
                                           v-if="!setting.readonly && !judgeWrite('zcglhtglpabspaceList')"
                          >
                            <template slot-scope="scope">
                              <el-button size="mini" type="text" class="JNPF-table-delBtn"
                                         @click="delzcglhtglpabspaceList(scope.$index)"
                              >删除
                              </el-button>
                            </template>
                          </el-table-column>
                        </el-table>
                        <div class="table-actions" @click="addzcglhtglpabspaceList()">
                          <!--                          <el-button type="text" icon="el-icon-plus">添加</el-button>-->
                          <Popup v-model="dataForm.newData.lastmodifytime"
                                 @addList="handleAddList"
                                 placeholder="请选择" clearable field="assetName" interfaceId="612769091110831365"
                                 :columnOptions="lastmodifytimecolumnOptions" propsValue="id" relationField="zcname"
                                 popupType="dialog"
                                 popupTitle="选择资产" popupWidth="800px"
                                 hasPage :pageSize="20"
                          >
                          </Popup>
                        </div>
                      </el-form-item>
                    </el-col>
                  </el-card>
                </el-col>

                <el-col :span="24">
                  <el-card class="mb-20" shadow="always" header="租金费用条款">

                    <el-row v-for="(item, index) in dataForm.newData.zcgl_htgl_pab_fytk" :key="index">
                      <el-row>

                        <el-col :span="6" v-if="judgeShow('jnpf_zcgl_htgl_pab_fytk_jnpf_startTime')"
                        >
                          <el-form-item label="关联资产"
                                        :prop="getItemProp_zcgl_htgl_pab_fytk(index, 'relatedSpace')"
                          >
                            <!--                            :disabled="judgeWrite('relatedSpace')"-->
                            <el-select multiple v-model="item.relatedSpace"
                                       clearable
                                       :style='{"width":"100%"}'
                                       @change="toGetArea(item)"
                            >
                              <el-option v-for="(item, index) in dataForm.newData.zcgl_htgl_pab_space1" :key="index"
                                         :label="item.zcname"
                                         :value="item.id" :disabled="item.disabled"
                              ></el-option>
                              <!--                        <el-form-item label="关联资产"-->
                              <!--                                      :prop="getItemProp_zcgl_htgl_pab_fytk(index, 'relatedSpace')"-->
                              <!--                        >-->
                              <!--                          &lt;!&ndash;                            :disabled="judgeWrite('relatedSpace')"&ndash;&gt;-->
                              <!--                          <el-select multiple v-model="item.relatedSpace"-->
                              <!--                                     clearable-->
                              <!--                                     :style='{"width":"100%"}'-->
                              <!--                                     @change="toGetArea(item)"-->
                              <!--                          >-->
                              <!--                            <el-option v-for="(item, index) in dataForm.zcgl_htgl_pab_space1" :key="index"-->
                              <!--                                       :label="item.zcname"-->
                              <!--                                       :value="item.id" :disabled="item.disabled"-->
                              <!--                            ></el-option>-->

                            </el-select>
                          </el-form-item>
                          <!--                          </el-select>-->
                          <!--                        </el-form-item>-->
                        </el-col>

                        <el-col :span="6" v-if="judgeShow('rentalArea')"
                        >
                          <el-form-item label="租赁面积㎡"
                                        prop="rentalArea"
                          >
                            <el-input v-model="dataForm.newData.rentalArea"
                                      placeholder="请输入" :disabled="judgeWrite('rentalArea')"
                                      clearable :style='{"width":"100%"}'
                            >
                            </el-input>
                          </el-form-item>
                        </el-col>

                        <el-col :span="6" v-if="judgeShow('jnpf_zcgl_htgl_pab_fytk_jnpf_startTime')"
                        >
                          <el-form-item
                            :prop="getItemProp_zcgl_htgl_pab_fytk(index, 'rentMethod')"
                            label="计租方式"
                          >
                            <!--                            :disabled="judgeWrite('relatedSpace')"-->
                            <el-select
                              v-model="item.rentMethod"
                              clearable
                              :style="{ width: '100%' }"
                            >
                              <el-option
                                label="固定租金"
                                value="固定租金"
                              ></el-option>
                            </el-select>
                          </el-form-item>
                        </el-col>

                        <el-col :span="6" v-if="judgeShow('jnpf_zcgl_htgl_pab_fytk_jnpf_startTime')"
                        >
                          <el-form-item label="费用项"
                                        :prop="getItemProp_zcgl_htgl_pab_fytk(index, 'expenseType')"
                          >
                            <!--                            :disabled="judgeWrite('relatedSpace')"-->
                            <el-select

                              v-model="item.expenseType"
                              clearable
                              :style="{ width: '100%' }"
                            >
                              <el-option
                                label="房屋租金"
                                value="1"
                              ></el-option>
                              <el-option
                                label="物业"
                                value="2"
                              ></el-option>
                            </el-select>
                          </el-form-item>
                        </el-col>
                      </el-row>

                      <el-row>

                        <el-col :span="6" v-if="judgeShow('jnpf_zcgl_htgl_pab_fytk_jnpf_taxRate')">
                          <el-form-item label="税率(%)" prop="jnpf_zcgl_htgl_pab_fytk_jnpf_taxRate">
                            <el-input-number
                              v-model="item.taxRate"
                              placeholder="数字文本"
                              :disabled="judgeWrite('jnpf_zcgl_htgl_pab_fytk_jnpf_taxRate')"
                              :step="0.01"
                              :precision="2"
                            />
                          </el-form-item>
                        </el-col>

                        <el-col :span="6" v-if="judgeShow('jnpf_zcgl_htgl_pab_fytk_jnpf_hsUnit')"
                        >
                          <el-form-item label="含税租金单价(元)"
                                        prop="hsUnitPrice"
                          >
                            <el-input-number v-model="item.hsUnitPrice"
                                             placeholder="数字文本"
                                             :disabled="judgeWrite('jnpf_zcgl_htgl_pab_fytk_jnpf_hsUnit')"
                                             :step="0.01"
                                             :precision="2"
                            >
                            </el-input-number>
                          </el-form-item>
                        </el-col>

                        <el-col :span="6" v-if="judgeShow('jnpf_zcgl_htgl_pab_fytk_jnpf_bhsUnit')"
                        >
                          <el-form-item label="不含税租金单价(元)"
                                        prop="bhsUnitPrice"
                          >
                            <el-input-number v-model="item.bhsUnitPrice"
                                             placeholder="数字文本"
                                             :disabled="judgeWrite('jnpf_zcgl_htgl_pab_fytk_jnpf_bhsUnit')"
                                             :step="0.01"
                                             :precision="2"
                            >
                            </el-input-number>
                          </el-form-item>
                        </el-col>

                        <el-col :span="6"
                        >
                          <el-form-item label="月租金(元)"
                                        :prop="getItemProp_zcgl_htgl_pab_fytk(index, 'monthlyRent')"
                          >
                            <el-input-number v-model="item.monthlyRent"
                                             placeholder="数字文本"
                                             :disabled="judgeWrite('jnpf_zcgl_htgl_pab_fytk_jnpf_bhsUnit')"
                                             :step="0.01"
                                             :precision="2"
                            >
                            </el-input-number>
                          </el-form-item>
                        </el-col>

                      </el-row>

                      <el-row>
                        <el-col :span="6"
                        >
                          <el-form-item label="保证金(元)"
                                        :prop="getItemProp_zcgl_htgl_pab_fytk(index, 'jnpf_zcgl_htgl_pab_fytk_jnpf_bhsUnit')"
                          >
                            <el-input-number v-model="item.earnestMoney"
                                             placeholder="数字文本"
                                             :disabled="judgeWrite('jnpf_zcgl_htgl_pab_fytk_jnpf_bhsUnit')"
                                             :step="0.01"
                                             :precision="2"
                            >
                            </el-input-number>
                          </el-form-item>
                        </el-col>

                        <el-col :span="6"
                        >
                          <el-form-item label="违约金(元)"
                                        :prop="getItemProp_zcgl_htgl_pab_fytk(index, 'jnpf_zcgl_htgl_pab_fytk_jnpf_bhsUnit')"
                          >
                            <el-input-number v-model="item.defaultMoney"
                                             placeholder="数字文本"
                                             :disabled="judgeWrite('jnpf_zcgl_htgl_pab_fytk_jnpf_bhsUnit')"
                                             :step="0.01"
                                             :precision="2"
                            >
                            </el-input-number>
                          </el-form-item>
                        </el-col>

                        <el-col style="display: flex" :span="6"
                                v-if="judgeShow('jnpf_zcgl_htgl_pab_fytk_jnpf_bhsUnit')"
                        >
                          <el-form-item label="付款周期(月)"
                                        placeholder="数字文本"
                                        :prop="getItemProp_zcgl_htgl_pab_fytk(index, 'paymentCycle')"

                          >
                            <el-input-number v-model="item.paymentCycle"
                                             :disabled="judgeWrite('jnpf_zcgl_htgl_pab_fytk_jnpf_bhsUnit')"
                                             :step="1"
                            >
                            </el-input-number>
                          </el-form-item>
                        </el-col>

                      </el-row>
                      <el-row>
                        <el-col :span="6">

                          <el-form-item label="是否递增"
                                        prop="ihis"
                          >
                            <el-switch v-model="item.isIncreasing"
                                       :disabled="judgeWrite('jnpf_zcgl_htgl_pab_fytk_jnpf_bhsUnit')" :active-value="1"
                                       :inactive-value="0"
                            >

                            </el-switch>
                          </el-form-item>
                        </el-col>


                        <el-col :span="16">
                          <el-form-item>

                            <el-button type="danger" @click.prevent="removeFytk(index)">删除</el-button>
                          </el-form-item>
                        </el-col>
                      </el-row>

                      <!--递增条款-->
                      <el-row>
                        <el-table
                          v-if="item.isIncreasing==1"
                          :data="item.listDz"
                          style="width: 100%"
                          border
                        >
                          <el-table-column
                            prop="start"
                            label="开始日期"
                            width="250"
                          />
                          <el-table-column
                            prop="end"
                            label="结束日期"
                            width="250"
                          />
                          <el-table-column
                            prop="rent"
                            label="租金单价"
                            width="250"
                          />
                          <el-table-column
                            prop="paymentDate"
                            label="付款日期"
                            width="250"
                          />
                          <el-table-column
                            prop="rent"
                            label="日期"
                            width="280"
                          />
                          <el-table-column
                            prop="increasePercent"
                            label="递增"
                            width="280"
                          />
                        </el-table>
                        <div v-if="item.isIncreasing==1" class="table-actions" @click="addzcglhtglpabspaceList()">
                          <el-button type="text" icon="el-icon-plus" @click="addDz(item)">批量新增递增条款</el-button>
                        </div>
                      </el-row>


                      <el-divider v-if="index < dataForm.newData.zcgl_htgl_pab_fytk.length - 1"></el-divider>

                    </el-row>
                    <el-row>

                      <div class="table-actions" @click="addzcglhtglpabspaceList()">
                        <!--                          <el-button type="text" icon="el-icon-plus">添加</el-button>-->
                        <el-button type="text" icon="el-icon-plus" @click="addFytk">添加费用</el-button>
                      </div>

                    </el-row>
                  </el-card>
                </el-col>

              </el-card>
            </template>
          </el-form>
        </el-tab-pane>
      </el-tabs>


    </el-row>
    <UserBox v-if="userBoxVisible" ref="userBox" @submit="submit"/>
    <SelectDialog v-if="selectDialogVisible" :config="addTableConf" :formData="dataForm" ref="selectDialog"
                  @select="addForSelect" @close="selectDialogVisible=false"
    />
  </div>
</template>

<script>
import request from '@/utils/request'
import { getDataInterfaceRes } from '@/api/systemData/dataInterface'
import { getDictionaryDataSelector } from '@/api/systemData/dictionary'
import SelectDialog from '@/components/SelectDialog'

export default {
  components: { SelectDialog },
  props: [],
  data() {
    return {
      lastmodifytimecolumnOptions: [
        {
          value: 'fid',
          label: 'ID'
        },
        {
          value: 'zcname',
          label: '资产名称'
        }
        , {
          value: 'zclabel',
          label: '资产标签'
        }
        ,
        {
          value: 'zcnumber',
          label: '资产编码'
        },

        {
          value: 'address',
          label: '地址'
        },
        {
          value: 'landarea',
          label: '面积'
        }
      ],
      zcNatureOptions: [],
      zcNatureProps: { 'label': 'fullName', 'value': 'id' },
      zcPurposeOptions: [],
      zcPurposeProps: { 'label': 'fullName', 'value': 'id' },
      zcSourceOptions: [],
      zcSourceProps: { 'label': 'fullName', 'value': 'id' },
      affiliatedUnitOptions: [],
      affiliatedUnitProps: { 'label': 'fullName', 'value': 'id' },
      managementUnitOptions: [],
      managementUnitProps: { 'label': 'fullName', 'value': 'id' },
      jnpf_zcgl_zcdj_warrant_jnpf_propertyRightOptions: [],
      jnpf_zcgl_zcdj_warrant_jnpf_propertyRightProps: { 'label': 'fullName', 'value': 'id' },
      jnpf_zcgl_zcdj_warrant_jnpf_useNatureOptions: [],
      jnpf_zcgl_zcdj_warrant_jnpf_useNatureProps: { 'label': 'fullName', 'value': 'id' },
      activexdivdv: '1',
      selectDialogVisible: false,
      tableKey: '',
      addTableConf: {},
      loading: false,
      visible: false,
      setting: {},
      eventType: '',
      userBoxVisible: false,
      tableRequiredData: {},
      primaryKeyPolicy: true,
      dataFormNew: {},
      paymentDeadlineTypeOptions: [],
      paymentDeadlineStatusOptions: [],
      contractTypeOptions: [],
      projectOptions: [],

      dataForm: {
        oldData: {

          zcNumber: ''
        },
        newData: {},
        id: '',
        flowId: '',
        status: 1,
        candidateList: {},
        freeapproveruserid: '',
        branchList: [],
        errorRuleUserList: {},
        flowUrgent: 1,
        version: 0,
        flowtaskid: undefined,
        copyIds: '',
        project: '',
        customerName: '',
        contractNo: '',
        paymentBy: '',
        billType: '',
        expenseStartDate: '',
        expenseEndDate: '',
        planReceiptDate: '',
        billRemark: '',
        zcbillitemList: [],
      },
      dataRule:
        {
          // zcgl_htgl_pab_fytk: [
          //   {
          //     monthlyRent: [
          //       { required: true, message: '请输入月租金', trigger: 'blur' },
          //       {
          //         validator: (rule, value, callback) => {
          //           if (!value || value.trim() === '') {
          //             callback(new Error('月租金不能为空'));
          //           } else {
          //             callback();
          //           }
          //         },
          //         trigger: 'blur',
          //       },
          //     ],
          //   },
          //   ],
          'contractNumber': [{ 'required': true, 'message': '合同编号不能为空', 'trigger': 'blur' }],
          'contractType': [{ 'required': true, 'message': '合同类型不能为空', 'trigger': 'blur' }],
          'signingDate': [{ 'required': true, 'message': '签订日期不能为空', 'trigger': 'blur' }],
          'effectiveDate': [{ 'required': true, 'message': '生效日期不能为空', 'trigger': 'blur' }],
          'partyName': [{ 'required': true, 'message': '甲方名称不能为空', 'trigger': 'blur' }],
          'partyContacts': [{ 'required': true, 'message': '甲方联系人不能为空', 'trigger': 'blur' }],
          'partyContactInformation': [{ 'required': true, 'message': '甲方联系方式不能为空', 'trigger': 'blur' }],
          'startTime': [{ 'required': true, 'message': '合同起始日期不能为空', 'trigger': 'blur' }],
          'endTime': [{ 'required': true, 'message': '合同结束日期不能为空', 'trigger': 'blur' }],
          'paymentDeadlineType': [{ 'required': true, 'message': '交费期限类型不能为空', 'trigger': 'blur' }],
          'paymentDeadline': [{ 'required': true, 'message': '交费期限日不能为空', 'trigger': 'blur' }],
          'jnpf_zcgl_htgl_pab_fytk_jnpf_startTime': [{ 'required': true, 'message': '租金开始日期不能为空', 'trigger': 'blur' }],
          'jnpf_zcgl_htgl_pab_fytk_jnpf_endTime': [{ 'required': true, 'message': '租金结束日期不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.0.relatedSpace': [{ 'required': true, 'message': '关联资产不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.1.relatedSpace': [{ 'required': true, 'message': '关联资产不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.2.relatedSpace': [{ 'required': true, 'message': '关联资产不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.3.relatedSpace': [{ 'required': true, 'message': '关联资产不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.0.monthlyRent': [{ 'required': true, 'message': '月租金不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.1.monthlyRent': [{ 'required': true, 'message': '月租金不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.2.monthlyRent': [{ 'required': true, 'message': '月租金不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.3.monthlyRent': [{ 'required': true, 'message': '月租金不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab.0.pabCustomerName': [{ 'required': true, 'message': '乙方客户名称0不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab.0.pabContactNumber': [{ 'required': true, 'message': '乙方客户电话0不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab.1.pabContactNumber': [{ 'required': true, 'message': '乙方客户电话1不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab.1.pabCustomerName': [{ 'required': true, 'message': '乙方客户名称1不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab.2.pabCustomerName': [{ 'required': true, 'message': '乙方客户名称2不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab.3.pabCustomerName': [{ 'required': true, 'message': '乙方客户名称3不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab.2.pabContactNumber': [{ 'required': true, 'message': '乙方客户电话2不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab.3.pabContactNumber': [{ 'required': true, 'message': '乙方客户电话3不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.0.rentMethod': [{ 'required': true, 'message': '费用类别0不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.1.rentMethod': [{ 'required': true, 'message': '费用类别1不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.2.rentMethod': [{ 'required': true, 'message': '费用类别2不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.3.rentMethod': [{ 'required': true, 'message': '费用类别3不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.0.expenseType': [{ 'required': true, 'message': '租金类别0不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.1.expenseType': [{ 'required': true, 'message': '租金类别1不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.2.expenseType': [{ 'required': true, 'message': '租金类别2不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.3.expenseType': [{ 'required': true, 'message': '租金类别3不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.0.startTime': [{ 'required': true, 'message': '开始日期1不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.1.startTime': [{ 'required': true, 'message': '开始日期2不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.2.startTime': [{ 'required': true, 'message': '开始日期3不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.3.startTime': [{ 'required': true, 'message': '开始日期4不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.0.endTime': [{ 'required': true, 'message': '结束日期1不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.1.endTime': [{ 'required': true, 'message': '结束日期2不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.2.endTime': [{ 'required': true, 'message': '结束日期3不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.3.endTime': [{ 'required': true, 'message': '结束日期4不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.0.cycleDivisionMethod': [{ 'required': true, 'message': '周期划分方式1不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.1.cycleDivisionMethod': [{ 'required': true, 'message': '周期划分方式2不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.2.cycleDivisionMethod': [{ 'required': true, 'message': '周期划分方式3不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.3.cycleDivisionMethod': [{ 'required': true, 'message': '周期划分方式4不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.0.paymentCycle': [{ 'required': true, 'message': '付款周期1不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.1.paymentCycle': [{ 'required': true, 'message': '付款周期2不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.2.paymentCycle': [{ 'required': true, 'message': '付款周期3不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.3.paymentCycle': [{ 'required': true, 'message': '付款周期4不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.0.paymentType': [{ 'required': true, 'message': '收款日1不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.1.paymentType': [{ 'required': true, 'message': '收款日2不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.2.paymentType': [{ 'required': true, 'message': '收款日3不能为空', 'trigger': 'blur' }],
          'zcgl_htgl_pab_fytk.3.paymentType': [{ 'required': true, 'message': '收款日4不能为空', 'trigger': 'blur' }]
        },
      zcgl_cw_bill_itemexpenseItemOptions: [{ 'fullName': '选项一', 'id': '1' }, { 'fullName': '选项二', 'id': '2' }],
      zcgl_cw_bill_itemexpenseItemProps: { 'label': 'fullName', 'value': 'id' }
    }
  },
  computed: {
    formOperates() {
      return this.setting.formOperates
    }
  },
  watch: {},
  created() {
    // this.getColumnList()
    // this.getcontractTypeOptions()
    // this.getprojectOptions()
    // this.getpaymentDeadlineTypeOptions()
    // this.getpaymentDeadlineStatusOptions()
    //
    this.getpaymentDeadlineTypeOptions()
    this.getpaymentDeadlineStatusOptions()
    this.getcontractTypeOptions()
    this.getprojectOptions()

  },
  mounted() {
  },
  methods: {
    removeFytk(index) {
      this.dataForm.newData.zcgl_htgl_pab_fytk.splice(index, 1)
    },
    getItemProp_zcgl_htgl_pab_fytk(index, prop) {
      // return `zcgl_htgl_pab[${index}].${prop}`
      return `zcgl_htgl_pab_fytk.${index}.${prop}`
    },
    handleAddList(checkedRow) {
      // 接收子组件传递的 checkedRow 数据
      this.dataForm.zcgl_htgl_pab_space1 = checkedRow
      // 你可以在这里处理接收到的数据
    },
    addFytk() {
      this.dataForm.newData.zcgl_htgl_pab_fytk.push({
        relatedSpace: [],
        startTime: null
      })
    },
    getItemProp(index, prop) {
      return `zcgl_htgl_pab.${index}.${prop}`;
    },
    getcontractTypeOptions() {
      getDictionaryDataSelector('622532919440706373').then(res => {
        this.contractTypeOptions = res.data.list
      })
    },
    getprojectOptions() {
      getDictionaryDataSelector('622532443626277701').then(res => {
        this.projectOptions = res.data.list
      })
    },
    getpaymentDeadlineTypeOptions() {
      getDictionaryDataSelector('622533108956138312').then(res => {
        this.paymentDeadlineTypeOptions = res.data.list
      })
    },
    getpaymentDeadlineStatusOptions() {
      getDictionaryDataSelector('622533108956138313').then(res => {
        this.paymentDeadlineStatusOptions = res.data.list
      })
    },
    updateDataRule() {
      let newRules = {}
      for (let i = 0; i < this.setting.formOperates.length; i++) {
        const item = this.setting.formOperates[i]
        if (!item.id.includes('-')) {
          const newRulesItem = {
            required: item.required || false,
            message: item.name + '不能为空',
            trigger: item.trigger || 'blur'
          }
          if (!this.dataRule.hasOwnProperty(item.id)) {
            if (item.required) this.$set(newRules, item.id, [newRulesItem])
          } else {
            let withoutRequiredItem = true
            for (let i = 0; i < this.dataRule[item.id].length; i++) {
              if (this.dataRule[item.id][i].hasOwnProperty('required')) {
                this.dataRule[item.id][i].required = item.required || false
                withoutRequiredItem = false
              }
            }
            if (withoutRequiredItem && item.required) this.dataRule[item.id].push(newRulesItem)
          }
        } else {
          let key = item.id.split('-')[0]
          let newId = item.id.split('-')[1]
          let newItem = {
            ...item,
            id: newId
          }
          if (!this.tableRequiredData.hasOwnProperty(key)) {
            this.$set(this.tableRequiredData, key, [newItem])
          } else {
            this.tableRequiredData[key].push(newItem)
          }
        }
      }
      this.dataRule = { ...this.dataRule, ...newRules }
    },
    exist() {
      let isOk = true
      let messageList = []
      for (let key in this.tableRequiredData) {
        let arr = this.tableRequiredData[key].filter((o) => o.required) || []
        for (let k = 0; k < arr.length; k++) {
          for (let i = 0; i < this.dataForm[key].length; i++) {
            let id = arr[k].id
            let name = arr[k].name
            let _data = this.dataForm[key][i][id]
            let boo = true
            if (Array.isArray(_data)) {
              boo = !this.jnpf.isEmptyArray(_data)
            } else {
              boo = !this.jnpf.isEmpty(_data)
            }
            if (!boo) {
              messageList.push(name + '不能为空')
            }
          }
        }
      }
      isOk = messageList.length == 0
      if (messageList.length > 0) {
        this.$message.error(messageList[0], 1000)
      }
      return isOk
    },
    dataAll() {
    },
    goBack() {
      this.$emit('refresh')
    },
    init(data) {
      if (data.flowTaskInfo != null) {

        console.log(data.flowTaskInfo)

        this.dataInfo3(data.flowTaskInfo.flowFormContentJson)
        this.$emit('setPageLoad')
        this.$store.commit('generator/UPDATE_RELATION_DATA', {})
        this.loading = false
        // this.dataForm.id = data.id || "";
        this.setting = data
        // this.visible = true;
        this.updateDataRule()

      } else {
        this.$store.commit('generator/UPDATE_RELATION_DATA', {})
        this.loading = true
        this.dataForm.id = data.id || ''
        this.setting = data
        this.visible = true

        this.$nextTick(() => {
          // this.$refs['elForm'].resetFields();
          if (this.dataForm.id) {
            let url = '/api/example/ZcglHtglInfo/' + this.dataForm.id
            if (this.dataForm.flowtaskid) {
              url += '?flowtaskid=' + this.dataForm.flowtaskid
            }
            request({
              url: url,
              method: 'get'
            }).then(res => {
              this.dataInfo(res.data)
              this.updateDataRule()
            })
          }
          this.loading = false
          this.$emit('setPageLoad')
        })
      }

    },
    // 表单提交
    dataFormSubmit(eventType, flowUrgent) {
      this.$refs['elForm'].validate((valid) => {
        if (valid) {
          if (!this.exist()) return
          if (eventType === 'audit' || eventType === 'reject') {
            var _data = this.dataList()
            this.$emit('eventReceiver', _data, eventType)
            return
          }
          this.dataForm.status = eventType === 'submit' ? 0 : 1
          this.dataForm.flowUrgent = flowUrgent
          this.dataForm.flowId = this.setting.flowId
          this.eventType = eventType
          if (this.eventType === 'submit') {
            this.$confirm('您确定要提交当前流程吗, 是否继续?', '提示', {
              type: 'warning'
            }).then(() => {
              this.request()
            }).catch(() => {
            })
          } else {
            this.request()
          }
        }
      })
    },
    request() {
      var _data = this.dataList()
      var id = this.dataForm.id
      delete this.dataForm.id
      // _data.oldData  = this.dataForm
      // _data.newData  = this.dataFormNew
      _data.type = '2'
      _data.htdgId = id
      if (true) {
        request({
          url: '/api/example/ZcglHtglInfoChange',
          method: 'post',
          data: _data
        }).then((res) => {
          this.$message({
            message: res.msg,
            type: 'success',
            duration: 1000,
            onClose: () => {
              this.visible = false
              this.$emit('close', true)
            }
          })
        })
      } else {
        request({
          url: '/api/ZcglCwBillChange/' + this.dataForm.id,
          method: 'PUT',
          data: _data
        }).then((res) => {
          this.$message({
            message: res.msg,
            type: 'success',
            duration: 1000,
            onClose: () => {
              this.visible = false
              this.$emit('close', true)
            }
          })
        })
      }
    },
    judgeShow(id) {
      if (!this.setting.formOperates || !this.setting.formOperates.length) return true
      let arr = this.setting.formOperates.filter(o => o.id === id) || []
      if (!arr.length) return true
      let item = arr[0]
      return item.read
    },
    judgeWrite(id) {

      if (!this.setting.formOperates || !this.setting.formOperates.length) return false
      let arr = this.setting.formOperates.filter(o => o.id === id) || []


      if (!arr.length) return true
      let item = arr[0]
      return !item.write
    },
    judgeRequired(id) {
      if (!this.setting.formOperates || !this.setting.formOperates.length) return false
      let arr = this.setting.formOperates.filter(o => o.id === id) || []
      if (!arr.length) return true
      let item = arr[0]
      return item.required
    },
    addzcbillitemList() {
      this.tableKey = 'zcbillitemList'
      let item = {
        expenseItem: undefined,
        receiveAmount: undefined
      }
      this.dataForm.zcbillitemList.push(item)
    },
    delzcbillitemList(index) {
      this.dataForm.zcbillitemList.splice(index, 1)
    },
    dataList() {
      var _data = JSON.parse(JSON.stringify(this.dataForm))

      return _data
    },
    dataInfo3(dataAll) {

      let _dataAll = JSON.parse(dataAll)

      console.log('asas阿萨·' + _dataAll)

      function safeParseJSON(data) {
        try {
          return typeof data === 'string' ? JSON.parse(data) : data
        } catch (e) {
          console.error('Parsing error:', e)
          return null // 或者根据需要返回其他默认值
        }
      }

// 处理 oldData 中的 zcFile 和 zcFmImage
      if (_dataAll.oldData) {
        let oldDataParsed = safeParseJSON(_dataAll.oldData)
        if (oldDataParsed) {
          if (oldDataParsed.zcFile != '') {
            oldDataParsed.zcFile = oldDataParsed.zcFile ? JSON.parse(oldDataParsed.zcFile) : []

          }
          if (oldDataParsed.zcFmImage != '') {
            oldDataParsed.zcFmImage = oldDataParsed.zcFmImage ? JSON.parse(oldDataParsed.zcFmImage) : []

          }

        }
      }

// 处理 newData 中的 zcFile 和 zcFmImage
      if (_dataAll.newData) {
        let newDataParsed = safeParseJSON(_dataAll.newData)
        if (newDataParsed) {
          if (newDataParsed.zcFile != '') {
            newDataParsed.zcFile = newDataParsed.zcFile ? JSON.parse(newDataParsed.zcFile) : []

          }
          if (newDataParsed.zcFmImage != '') {
            newDataParsed.zcFmImage = newDataParsed.zcFmImage ? JSON.parse(newDataParsed.zcFmImage) : []

          }

        }
      }

      this.dataForm = _dataAll
      if (typeof this.dataForm.oldData === 'string') {

        this.dataForm.oldData = JSON.parse(this.dataForm.oldData)

      } else {
        this.dataForm.oldData = this.dataForm.oldData
      }

      if (typeof this.dataForm.newData === 'string') {
        this.dataForm.newData = JSON.parse(this.dataForm.newData)

      } else {
        this.dataForm.newData = this.dataForm.newData
      }


      // this.dataFormNew = JSON.parse(JSON.stringify(this.dataForm))
    },
    dataInfo(dataAll) {
      let _dataAll = dataAll

      _dataAll.zcgl_htgl_pab_space1 = _dataAll.zcgl_htgl_pab_space

      for (let i = 0; i < dataAll.zcgl_htgl_pab_space1.length; i++) {
        dataAll.zcgl_htgl_pab_space1[i].zcname = dataAll.zcgl_htgl_pab_space1[i].zcName
        dataAll.zcgl_htgl_pab_space1[i].zcnumber = dataAll.zcgl_htgl_pab_space1[i].zcNumber
        dataAll.zcgl_htgl_pab_space1[i].id = dataAll.zcgl_htgl_pab_space1[i].zcId
      }
      for (let i = 0; i < dataAll.zcgl_htgl_pab_fytk.length; i++) {
        dataAll.zcgl_htgl_pab_fytk[i].relatedSpace = dataAll.zcgl_htgl_pab_fytk[i].relatedSpace.split(",")
      }



      this.dataForm.oldData = _dataAll

      this.dataForm.newData = JSON.parse(JSON.stringify(this.dataForm.oldData))




    },
    dataInfo2(dataAll) {
      let _dataAll = dataAll

      if (_dataAll.zcFile != null && dataAll.zcFile != '') {
        _dataAll.zcFile = JSON.parse(_dataAll.zcFile)

      } else {
        _dataAll.zcFile = ''
      }
      if (_dataAll.zcFmImage != null && dataAll.zcFmImage != '') {
        _dataAll.zcFmImage = JSON.parse(_dataAll.zcFmImage)

      } else {
        _dataAll.zcFmImage = ''
      }
      this.dataForm = _dataAll


      this.$forceUpdate()

    },
    dataInfo1(dataAll) {
      let _dataAll = dataAll
      // for(let i=0;i<_dataAll.zcbillitemList.length;i++){
      //   var _list = _dataAll.zcbillitemList[i];
      //   _list.expenseItem = _list.expenseItem
      // }
      if (_dataAll.zcFile != null && dataAll.zcFile != '') {
        _dataAll.zcFile = JSON.parse(_dataAll.zcFile)

      } else {
        _dataAll.zcFile = ''
      }
      this.dataForm.newData = _dataAll
    },
    addForSelect(data) {
      for (let i = 0; i < data.length; i++) {
        let item = data[i]
        this.dataForm[this.tableKey].push(item)
      }
    }
  }
}

</script>
